import Vue from 'vue'
import Vuex from 'vuex'
// 1引入持久化插件
import vuexPersistedstate from "vuex-persistedstate";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    username:'',
    token:''
  },
  getters: {
  },
  mutations: {
    setUsername (state, username) {
      state.username = username
    },
    destroyUserInfo (state) {
      state.username = ''
    },
    setToken (state, token) {
      state.token = token
    }
  },
  actions: {
  },
  modules: {
  },
  plugins:[vuexPersistedstate()] // 2加入插件
})
